<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>SSDB PHP Client API Documentation</title>
	<meta name="keywords" content="SSDB, leveldb, zset, key-value, database" />

	<style type="text/css">
	body{
		margin: 4px;
		padding: 0;
		font-size: 13px;
		font-family: tahoma, arial;
		background: #fff;
	}
	table{
		border-collapse: collapse;
	}
	th, td{
		padding: 4px;
		border: 1px solid #999;
	}
	pre{
		padding: 6px;
		background: #eee;
	}
	code{
		color: #c00;
		background: #eee;
	}
	h1{font-size: 220%;}
	h2{font-size: 180%; border-bottom: 1px solid #999;}
	h3{font-size: 150%; border-bottom: 1px solid #ccc;}
	h4{font-size: 110%;}
	#footer{
		margin-top: 40px;
		padding: 8px;
		border-top: 1px solid #ccc;
	}
	h4 em{font-weight: bold;}
	</style>
</head>
<body>

<p style="float: right; margin-right: 10px;">
	<a href="https://github.com/ideawu/ssdb-docs" target="_blank">Improve this page on GitHub</a>
</p>

<h1>SSDB PHP Client API Documentation</h1>

<dl>
	<dd>@author: <a href="http://www.ideawu.com/">ideawu</a></dd>
	<dd>@updated: 2014-11-05</dd>
</dl>

<p>SSDB is a high performance NoSQL database, an alternative for Redis, the official website is <a href="http://ssdb.io/" target="_blank">http://ssdb.io</a>. This documentation describes the PHP client API of SSDB.</p>

<p>Notice: The phrases "hashmap", "hash", "map" are equivelant in SSDB.</p>

<h2>Class SimpleSSDB</h2>

<a name="m-quick_start"></a>
<h3><em>Quick Start</em></h3>

<pre>
&lt;?php
include_once('SSDB.php');
try{
    $ssdb = new SimpleSSDB('127.0.0.1', 8888);
}catch(Exception $e){
    die(__LINE__ . ' ' . $e-&gt;getMessage());
}
$ret = $ssdb-&gt;set('key', 'value');
if($ret === false){
    // error!
}
echo $ssdb-&gt;get('key');
</pre>

<a name="m-error_handling"></a>
<h3>Error Handling</h3>

<p>SimpleSSDB throws Exception if it can't connect to SSDB server. Most methods(with some exceptions) return <code>false</code> on error. So one should use Identical Equal(===) to test the return value.</p>

<p><b>All methods will throw SSDBException on network error.</b></p>

<p><b>WARN: make sure all arguments do not exceed 10MB total size.</b></p>


<h2>Methods</h2>

<a name="m-construct"></a>
<h3>SimpleSSDB::__construct</h3>

<h4><em>Description</em></h4>
<p>Creates a SSDB client, and connect to SSDB server. Throws exception if it can't connect to the server.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>host</code> - SSDB server's host/ip address.</dd>
	<dd><code>port</code> - SSDB server's port number.</dd>
	<dd><code>timeout_ms</code> - optional, timeout for connect, send/receive data, in milliseconds. Default 2000 ms.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>The SimpleSSDB instance.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb = new SimpleSSDB('127.0.0.1', 8888);
</pre>


<a name="m-auth"></a>
<h3>auth</h3>
<p>Since: 1.7.0.0</p>

<h4><em>Description</em></h4>
<p>Config the password for later use to authenticate the connection. The authentication is not invoked immediately, but later when you send the first request to the server. <b>Warning: The password is sent in plain-text over the network!</b></p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>password</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise returns <code>null</code>.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;auth('very-strong-password');
</pre>



<!-- ##############  key value ############## -->

<a name="m-set"></a>
<h3>set</h3>

<h4><em>Description</em></h4>
<p>Set the value of the key.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>value</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;set('key', 'value');
</pre>


<a name="m-setx"></a>
<h3>setx</h3>

<h4><em>Description</em></h4>
<p>Set the value of the key, with a time to live.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>value</code> - </dd>
	<dd><code>ttl</code> - number of seconds to live.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;setx('key', 'value', 60);
</pre>


<a name="m-setnx"></a>
<h3>setnx</h3>

<h4><em>Description</em></h4>
<p>Set the string value in argument as value of the key if and only if the key doesn't exist.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>value</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, 1: value is set, 0: key already exists.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;setnx('key', 'value');
</pre>


<a name="m-expire"></a>
<h3>expire</h3>

<h4><em>Description</em></h4>
<p>Set the time left to live in seconds, only for keys of KV type.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>ttl</code> - number of seconds to live.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, if key exists and ttl is set, return 1, if key not exists, return 0.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;expire('key', 60);
</pre>


<a name="m-ttl"></a>
<h3>ttl</h3>

<h4><em>Description</em></h4>
<p>Returns the time left to live in seconds, only for keys of KV type.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, or time to live of the key, in seconds, -1 if there is no associated expire to the key.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;ttl('key');
</pre>


<a name="m-get"></a>
<h3>get</h3>

<h4><em>Description</em></h4>
<p>Get the value related to the specified key</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p>Returns <code>null</code> if key not found, <code>false</code> on error, otherwise, the value related to that key is returned.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;get('key');
</pre>


<a name="m-getset"></a>
<h3>getset</h3>

<h4><em>Description</em></h4>
<p>Sets a value and returns the previous entry at that key.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>value</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p>Returns <code>null</code> if key not found, <code>false</code> on error, therwise, the value related to that key is returned.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;getset('key', 'value');
</pre>


<a name="m-del"></a>
<h3>del</h3>

<h4><em>Description</em></h4>
<p>Delete specified key.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK. You can not determine whether the key exists or not.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;del('key');
</pre>


<a name="m-incr"></a>
<h3>incr</h3>

<p><b>Since 1.7.0.1, *incr methods return error if value cannot be converted to integer.</b></p>

<h4><em>Description</em></h4>
<p>Increment the number stored at <code>key</code> by <code>num</code>. The <code>num</code> argument could be a negative integer. The old number is first converted to an integer before increment, assuming it was stored as literal integer.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>num</code> - Must be a signed integer.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values the new value.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;incr('key', 1);
</pre>


<a name="m-exists"></a>
<h3>exists</h3>

<h4><em>Description</em></h4>
<p>Verify if the specified key exists.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p>If the key exists, return <code>true</code>, otherwise return <code>false</code>.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;exists('key');
</pre>


<a name="m-getbit"></a>
<h3>getbit</h3>

<h4><em>Description</em></h4>
<p>Return a single bit out of a string.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>offset</code> - bit offset.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>0 or 1.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;getbit('key', 7);
</pre>


<a name="m-setbit"></a>
<h3>setbit</h3>

<h4><em>Description</em></h4>
<p>Changes a single bit of a string. The string is auto expanded.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>offset</code> - bit offset, must in range of [0, 1073741824].</dd>
	<dd><code>val</code> - 0 or 1.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>The value of the bit before it was set: 0 or 1. If <code>val</code> is not 0 or 1, returns <code>false</code>.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;setbit('key', 7, 1);
</pre>


<a name="m-bitcount"></a>
<h3>bitcount</h3>

<h4><em>Description</em></h4>
<p>Like Redis's <a href="http://redis.io/commands/bitcount">bitcount</a>.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>start</code> - Optional, if <code>start</code> is negative, count from start'th character from the end of string.</dd>
	<dd><code>end</code> - Optional.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>The number of bits set to 1.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;bitcount('key', 2, 10);
</pre>


<a name="m-countbit"></a>
<h3>countbit</h3>

<h4><em>Description</em></h4>
<p>Count the number of set bits (population counting) in part of a string.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>start</code> - Optional, if <code>start</code> is negative, count from start'th character from the end of string.</dd>
	<dd><code>size</code> - Optional, if <code>size</code> is negative, then that many characters will be omitted from the end of string.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>The number of bits set to 1.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;countbit('key', 2, 10);
</pre>


<a name="m-substr"></a>
<h3>substr</h3>

<h4><em>Description</em></h4>
<p>Return part of a string(like PHP's <a href="http://php.net/substr">substr()</a>).</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
	<dd><code>start</code> - Optional, the offset of first byte returned. If <code>start</code> is negative, the returned string will start at the start'th character from the end of string.</dd>
	<dd><code>size</code> - Optional, number of bytes returned. If <code>size</code> is negative, then that many characters will be omitted from the end of string.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>The extracted part of the string.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;substr('key', 2, 10);
</pre>


<a name="m-strlen"></a>
<h3>strlen</h3>

<h4><em>Description</em></h4>
<p>Return the number of bytes of a string.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p>The number of bytes of the string, if key not exists, returns 0.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;strlen('key');
</pre>


<a name="m-keys"></a>
<h3>keys/rkeys</h3>

<h4><em>Description</em></h4>
<p>List keys in range (key_start, key_end].</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key_start</code> - The lower bound(not included) of keys to be returned, empty string means -inf(no limit).</dd>
	<dd><code>key_end</code> - The upper bound(inclusive) of keys to be returned, empty string means +inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many elements will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing the keys.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;keys('a', 'z', 10);
</pre>


<a name="m-scan"></a>
<h3>scan</h3>

<h4><em>Description</em></h4>
<p>List key-value pairs with keys in range (key_start, key_end].</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key_start</code> - The lower bound(not included) of keys to be returned, empty string means -inf(no limit).</dd>
	<dd><code>key_end</code> - The upper bound(inclusive) of keys to be returned, empty string means +inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many pairs will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing the key-value pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;scan('a', 'z', 10);
</pre>

<b>Iterate over all key-value pairs</b>
<pre>
$start = ''; 
$limit = 1000;
while(1){
    $kvs = $ssdb-&gt;scan($start, '', $limit);
    if(!$kvs){
        break;
    }
    // do something on key-value pairs...
    $keys = array_keys(array_slice($kvs, -1, 1, true));
    $max_key = $keys[0];
    $start = $max_key;
}
</pre>


<a name="m-rscan"></a>
<h3>rscan</h3>

<h4><em>Description</em></h4>
<p>List key-value pairs with keys in range (key_start, key_end], in reverse order.</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>key_start</code> - The upper bound(not included) of keys to be returned, empty string means +inf(no limit).</dd>
	<dd><code>key_end</code> - The lower bound(inclusive) of keys to be returned, empty string means -inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many pairs will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing the key-value pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;rscan('a', 'z', 10);
</pre>


<a name="m-multi_set"></a>
<h3>multi_set</h3>

<h4><em>Description</em></h4>
<p>Set multiple key-value pairs(kvs) in one method call.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>kvs</code> - A associative array containing the key-value pairs.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_set(array(
	'a' =&gt; 1,
	'b' =&gt; 2,
));
</pre>


<a name="m-multi_get"></a>
<h3>multi_get</h3>

<h4><em>Description</em></h4>
<p>Get the values related to the specified multiple keys</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>keys</code> - An array containing keys</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing ONLY found keys and values.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_get(array('k1', 'k2'));
</pre>


<a name="m-multi_del"></a>
<h3>multi_del</h3>

<h4><em>Description</em></h4>
<p>Delete specified multiple keys.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>keys</code> - An array containing keys</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_del(array('k1', 'k2'));
</pre>



<!-- ##############  map(hashmap) ############## -->

<a name="m-hset"></a>
<h3>hset</h3>

<h4><em>Description</em></h4>
<p>Set the string value in argument as value of the key of a hashmap.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
	<dd><code>key</code> - The key of the key-value pair in the hashmap</dd>
	<dd><code>value</code> - The value of the key-value pair in the hashmap</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hset('h', 'key', 'value');
</pre>


<a name="m-hget"></a>
<h3>hget</h3>

<h4><em>Description</em></h4>
<p>Get the value related to the specified key of a hashmap</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
	<dd><code>key</code> - The key of the key-value pair in the hashmap</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>Returns <code>null</code> if key not found, <code>false</code> on error, otherwise, the value related to this key is returned.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hget('h', 'key');
</pre>


<a name="m-hdel"></a>
<h3>hdel</h3>

<h4><em>Description</em></h4>
<p>Delete specified key of a hashmap.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
	<dd><code>key</code> - The key of the key-value pair in the hashmap</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK. You can not determine whether the key exists or not.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hdel('h', 'key');
</pre>


<a name="m-hincr"></a>
<h3>hincr</h3>

<p><b>Since 1.7.0.1, *incr methods return error if value cannot be converted to integer.</b></p>

<h4><em>Description</em></h4>
<p>Increment the number stored at <code>key</code> in a hashmap by <code>num</code>. The <code>num</code> argument could be a negative integer. The old number is first converted to an integer before increment, assuming it was stored as literal integer.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
	<dd><code>key</code> - </dd>
	<dd><code>num</code> - Must be a signed integer.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values the new value.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hincr('h', 'key', 1);
</pre>


<a name="m-hexists"></a>
<h3>hexists</h3>

<h4><em>Description</em></h4>
<p>Verify if the specified key exists in a hashmap.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
	<dd><code>key</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p>If the key exists, return <code>true</code>, otherwise return <code>false</code>.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hexists('h', 'key');
</pre>


<a name="m-hsize"></a>
<h3>hsize</h3>

<h4><em>Description</em></h4>
<p>Return the number of pairs of a hashmap.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an integer, 0 if the hashmap does not exist.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hsize('h');
</pre>


<a name="m-hlist"></a>
<h3>hlist, hrlist</h3>

<h4><em>Description</em></h4>
<p>List hashmap names in range (name_start, name_end].</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name_start</code> - The lower bound(not included) of names to be returned, empty string means -inf(no limit).</dd>
	<dd><code>name_end</code> - The upper bound(inclusive) of names to be returned, empty string means +inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many elements will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing the names.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hlist('a', 'z', 10);
</pre>


<a name="m-hkeys"></a>
<h3>hkeys</h3>

<h4><em>Description</em></h4>
<p>List keys of a hashmap in range (key_start, key_end].</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
	<dd><code>key_start</code> - The lower bound(not included) of keys to be returned, empty string means -inf(no limit).</dd>
	<dd><code>key_end</code> - The upper bound(inclusive) of keys to be returned, empty string means +inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many elements will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing the keys.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hkeys('h', 'a', 'z', 10);
</pre>


<a name="m-hgetall"></a>
<h3>hgetall</h3>

<h4><em>Description</em></h4>
<p>Returns the whole hash, as an array of strings indexed by strings.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing the key-value pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hgetall('h');
</pre>


<a name="m-hscan"></a>
<h3>hscan</h3>

<h4><em>Description</em></h4>
<p>List key-value pairs of a hashmap with keys in range (key_start, key_end].</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
	<dd><code>key_start</code> - The lower bound(not included) of keys to be returned, empty string means -inf(no limit).</dd>
	<dd><code>key_end</code> - The upper bound(inclusive) of keys to be returned, empty string means +inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many pairs will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing the key-value pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hscan('h', 'a', 'z', 10);
</pre>

<p>Iterate over a hash:</p>

<pre>
$start = '';
while(1){
    $kvs = $ssdb-&gt;hscan($name, $start, '', 10);
    if(!$kvs){
        break;
    }
    // do sth on kvs here
    
    $keys = array_keys($kvs);
    $start = $keys[count($keys) - 1];
}
</pre>



<a name="m-hrscan"></a>
<h3>hrscan</h3>

<h4><em>Description</em></h4>
<p>List key-value pairs of a hashmap with keys in range (key_start, key_end], in reverse order.</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap</dd>
	<dd><code>key_start</code> - The upper bound(not included) of keys to be returned, empty string means +inf(no limit).</dd>
	<dd><code>key_end</code> - The lower bound(inclusive) of keys to be returned, empty string means -inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many pairs will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing the key-value pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hrscan('h', 'a', 'z', 10);
</pre>


<a name="m-hclear"></a>
<h3>hclear</h3>

<h4><em>Description</em></h4>
<p>Delete all keys in a hashmap.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, or the number of keys deleted.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;hclear('h');
</pre>


<a name="m-multi_hset"></a>
<h3>multi_hset</h3>

<h4><em>Description</em></h4>
<p>Set multiple key-value pairs(kvs) of a hashmap in one method call.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap.</dd>
	<dd><code>kvs</code> - A associative array containing the key-value pairs.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_hset('h', array(
	'a' =&gt; 1,
	'b' =&gt; 2,
));
</pre>


<a name="m-multi_hget"></a>
<h3>multi_hget</h3>

<h4><em>Description</em></h4>
<p>Get the values related to the specified multiple keys of a hashmap.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap.</dd>
	<dd><code>keys</code> - An array containing keys.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing ONLY found keys and values.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_hget('h', array('k1', 'k2'));
</pre>


<a name="m-multi_hdel"></a>
<h3>multi_hdel</h3>

<h4><em>Description</em></h4>
<p>Delete specified multiple keys in a hashmap.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the hashmap.</dd>
	<dd><code>keys</code> - An array containing keys.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_hdel('h', array('k1', 'k2'));
</pre>




<!-- ##############  zset(sorted set) ############## -->

<a name="m-zset"></a>
<h3>zset</h3>

<h4><em>Description</em></h4>
<p>Set the score of the key of a zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
	<dd><code>key</code> - The key of the key-score pair in the hashmap</dd>
	<dd><code>score</code> - The score of the key-score pair in the hashmap</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zset('z', 'key', 100);
</pre>


<a name="m-zget"></a>
<h3>zget</h3>

<h4><em>Description</em></h4>
<p>Get the score related to the specified key of a zset</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
	<dd><code>key</code> - The key of the key-score pair in the zset</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>Returns <code>null</code> if key not found, <code>false</code> on error, otherwise, the score related to this key is returned.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zget('z', 'key');
</pre>


<a name="m-zdel"></a>
<h3>zdel</h3>

<h4><em>Description</em></h4>
<p>Delete specified key of a zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
	<dd><code>key</code> - The key of the key-score pair in the zset</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK. You can not determine whether the key exists or not.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zdel('hz, 'key');
</pre>


<a name="m-zincr"></a>
<h3>zincr</h3>

<h4><em>Description</em></h4>
<p>Increment the number stored at <code>key</code> in a zset by <code>num</code>. The <code>num</code> argument could be a negative integer. The old number is first converted to an integer before increment, assuming it was stored as literal integer.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
	<dd><code>key</code> - </dd>
	<dd><code>num</code> - Must be a signed integer.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values the new value.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zincr('z', 'key', 1);
</pre>


<a name="m-zexists"></a>
<h3>zexists</h3>

<h4><em>Description</em></h4>
<p>Verify if the specified key exists in a zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
	<dd><code>key</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p>If the key exists, return <code>true</code>, otherwise return <code>false</code>.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zexists('z', 'key');
</pre>


<a name="m-zsize"></a>
<h3>zsize</h3>

<h4><em>Description</em></h4>
<p>Return the number of pairs of a zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an integer, 0 if the zset does not exist.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zsize('z');
</pre>


<a name="m-zlist"></a>
<h3>zlist, zrlist</h3>

<h4><em>Description</em></h4>
<p>List zset names in range (name_start, name_end].</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name_start</code> - The lower bound(not included) of names to be returned, empty string means -inf(no limit).</dd>
	<dd><code>name_end</code> - The upper bound(inclusive) of names to be returned, empty string means +inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many elements will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing the names.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zlist('a', 'z', 10);
</pre>


<a name="m-zkeys"></a>
<h3>zkeys</h3>
<p>List keys in a zset. See method <code><a href="#m-zscan">zscan()</a></code>.</p>

<h4><em>Description</em></h4>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
	<dd><code>key_start</code> - See method <code><a href="#m-zscan">zscan()</a></code>.</dd>
	<dd><code>score_start</code> - See method <code><a href="#m-zscan">zscan()</a></code>.</dd>
	<dd><code>score_end</code> - See method <code><a href="#m-zscan">zscan()</a></code>.</dd>
	<dd><code>limit</code> - Up to that many elements will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing the keys.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zkeys('z', '', 1, 100, 10);
</pre>


<a name="m-zscan"></a>
<h3>zscan</h3>

<h4><em>Description</em></h4>
<p>List key-score pairs in a zset, where key-score in range (key_start+score_start, score_end]. If key_start is empty, keys with a score greater than or equal to score_start will be returned. If key_start is not empty, keys with score larger than score_start, and keys larger than key_start also with score equal to score_start will be returned.</p>

<p>That is: return keys in <code>(key.score == score_start &amp;&amp; key &gt; key_start || key.score &gt; score_start), and key.score &lt;= score_end</code>. The <code>score_start, score_end</code> is of higher priority than <code>key_start</code>.</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
	<dd><code>key_start</code> - The key related to score_start, could be empty string.</dd>
	<dd><code>score_start</code> - The minimum score related to keys(may not be included, depend on key_start), empty string means -inf(no limit).</dd>
	<dd><code>score_end</code> - The maximum score(inclusive) related to keys, empty string means +inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many pairs will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing the key-score pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zscan('z', '', 1, 100, 10);
</pre>

<p>Iterate over zset:</p>
<pre>
$key_start = ''; 
$score_start = ''; 
while(1){
    $items = $ssdb-&gt;zscan($zname, $key_start, $score_start, '', 10);
    if(!$items){
        break;
    }   
    foreach($items as $key=&gt;$score){
        // process($key, $score)...

        // remember the currently largest key and its score
        $key_start = $key;
        $score_start = $score;
    }   
}
</pre>


<a name="m-zrscan"></a>
<h3>zrscan</h3>

<h4><em>Description</em></h4>
<p>List key-score pairs of a zset, in reverse order. See method <code><a href="#m-zkeys">zkeys()</a></code>.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset</dd>
	<dd><code>key_start</code> - See method <code><a href="#m-zkeys">zkeys()</a></code>.</dd>
	<dd><code>score_start</code> - See method <code><a href="#m-zkeys">zkeys()</a></code>.</dd>
	<dd><code>score_end</code> - See method <code><a href="#m-zkeys">zkeys()</a></code>.</dd>
	<dd><code>limit</code> - Up to that many pairs will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing the key-score pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zrscan('z', '', 100, 1, 10);
</pre>


<a name="m-zrank"></a>
<h3>zrank, zrrank</h3>

<h4><em>Description</em></h4>
<p><b>Important! This method may be extremly SLOW! May not be used in an online service.</b></p>
<p>Returns the rank(index) of a given key in the specified sorted set, starting at 0 for the item with the smallest score. zrrank starts at 0 for the item with the largest score.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>key</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise the rank(index) of a specified key, start at 0. <code>null</code> if not found.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zrank('z', 'k1');
</pre>


<a name="m-zrange"></a>
<h3>zrange, zrrange</h3>

<h4><em>Description</em></h4>
<p><b>Important! This method is SLOW for large <code>offset</code>!</b></p>
<p>Returns a range of key-score pairs by index range [offset, offset + limit). Zrrange iterates in reverse order.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>offset</code> - Positive integer, the returned pairs will start at this offset.</dd>
	<dd><code>limit</code> - Positive integer, up to this number of pairs will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing key-score pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zrange('z', 0, 10);
</pre>


<a name="m-zclear"></a>
<h3>zclear</h3>

<h4><em>Description</em></h4>
<p>Delete all keys in a zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, or the number of keys deleted.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zclear('z');
</pre>


<a name="m-zcount"></a>
<h3>zcount</h3>

<h4><em>Description</em></h4>
<p>Returns the number of elements of the sorted set stored at the specified key which have scores in the range [start,end].</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>start</code> - The minimum score related to keys(inclusive), empty string means -inf(no limit).</dd>
	<dd><code>end</code> - The maximum score related to keys(inclusive), empty string means +inf(no limit).</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, or the number of keys in specified range.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zcount('z', 0, 100);
</pre>


<a name="m-zsum"></a>
<h3>zsum</h3>

<h4><em>Description</em></h4>
<p>Returns the sum of elements of the sorted set stored at the specified key which have scores in the range [start,end].</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>start</code> - The minimum score related to keys(inclusive), empty string means -inf(no limit).</dd>
	<dd><code>end</code> - The maximum score related to keys(inclusive), empty string means +inf(no limit).</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, or the sum of keys in specified range.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zsum('z', 0, 100);
</pre>


<a name="m-zavg"></a>
<h3>zavg</h3>

<h4><em>Description</em></h4>
<p>Returns the average of elements of the sorted set stored at the specified key which have scores in the range [start,end].</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>start</code> - The minimum score related to keys(inclusive), empty string means -inf(no limit).</dd>
	<dd><code>end</code> - The maximum score related to keys(inclusive), empty string means +inf(no limit).</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, or the average of keys in specified range.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zavg('z', 0, 100);
</pre>


<a name="m-zremrangebyrank"></a>
<h3>zremrangebyrank</h3>

<h4><em>Description</em></h4>
<p>Delete the elements of the zset which have rank in the range [start,end].</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>start</code> - inclusive, unsigned number.</dd>
	<dd><code>end</code> - inclusive, unsigned number.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, or the number of deleted elements.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zremrangebyrank('z', 1, 2);
</pre>


<a name="m-zremrangebyscore"></a>
<h3>zremrangebyscore</h3>

<h4><em>Description</em></h4>
<p>Delete the elements of the zset which have score in the range [start,end].</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>start</code> - (inclusive).</dd>
	<dd><code>end</code> - (inclusive).</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, or the number of deleted elements.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zremrangebyscore('z', 1, 2);
</pre>


<a name="m-zpop_front"></a>
<h3>zpop_front</h3>

<h4><em>Description</em></h4>
<p>Delete and return `limit` element(s) from front of the zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>limit</code> - The number of elements to be deleted and returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing key-score pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zpop_front('z', 3);
</pre>


<a name="m-zpop_back"></a>
<h3>zpop_back</h3>

<h4><em>Description</em></h4>
<p>Delete and return `limit` element(s) from back of the zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>limit</code> - The number of elements to be deleted and returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing key-score pairs.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;zpop_back('z', 3);
</pre>


<a name="m-multi_zset"></a>
<h3>multi_zset</h3>

<h4><em>Description</em></h4>
<p>Set multiple key-score pairs(kvs) of a zset in one method call.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>kvs</code> - A associative array containing the key-score pairs.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_zset('z', array(
	'a' =&gt; 1,
	'b' =&gt; 2,
));
</pre>


<a name="m-multi_zget"></a>
<h3>multi_zget</h3>

<h4><em>Description</em></h4>
<p>Get the values related to the specified multiple keys of a zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>keys</code> - An array containing keys.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an associative array containing ONLY found keys and values.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_zget('z', array('k1', 'k2'));
</pre>


<a name="m-multi_zdel"></a>
<h3>multi_zdel</h3>

<h4><em>Description</em></h4>
<p>Delete specified multiple keys of a zset.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - The name of the zset.</dd>
	<dd><code>keys</code> - An array containing keys.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;multi_zdel('z', array('k1', 'k2'));
</pre>





<a name="m-qsize"></a>
<h3>qsize</h3>

<h4><em>Description</em></h4>
<p>Returns the number of items in the queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an integer, 0 if the queue does not exist.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qsize('q');
</pre>


<a name="m-qlist"></a>
<h3>qlist, qrlist</h3>

<h4><em>Description</em></h4>
<p>List list/queue names in range (name_start, name_end].</p>

<p>("", ""] means no range limit.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name_start</code> - The lower bound(not included) of names to be returned, empty string means -inf(no limit).</dd>
	<dd><code>name_end</code> - The upper bound(inclusive) of names to be returned, empty string means +inf(no limit).</dd>
	<dd><code>limit</code> - Up to that many elements will be returned.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing the names.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qlist('a', 'z', 10);
</pre>



<a name="m-qclear"></a>
<h3>qclear</h3>

<h4><em>Description</em></h4>
<p>Clear the queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qclear('q');
</pre>




<a name="m-qfront"></a>
<h3>qfront</h3>

<h4><em>Description</em></h4>
<p>Returns the first element of a queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, <code>null</code> if queue empty, otherwise the item returned.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qfront('q');
</pre>


<a name="m-qback"></a>
<h3>qback</h3>

<h4><em>Description</em></h4>
<p>Returns the last element of a queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, <code>null</code> if queue empty, otherwise the item returned.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qback('q');
</pre>


<a name="m-qget"></a>
<h3>qget</h3>

<h4><em>Description</em></h4>
<p>Returns the element a the specified index(position). 0 the first element, 1 the second ... -1 the last element.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>index</code> - negative intexes accepted.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, <code>null</code> if no element corresponds to this index, otherwise the item returned.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qget('q', -2);
</pre>


<a name="m-qset"></a>
<h3>qset</h3>
<p>Since: 1.7.0.0</p>

<h4><em>Description</em></h4>
<p>Sets the list element at index to value. An error is returned for out of range indexes.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>index</code> - negative intexes accepted.</dd>
	<dd><code>val</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, other values indicate OK.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qset('q', 0, 'new val');
</pre>


<a name="m-qrange"></a>
<h3>qrange</h3>

<h4><em>Description</em></h4>
<p>Returns a portion of elements from the queue at the specified range [offset, offset + limit].</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>offset</code> - </dd>
	<dd><code>limit</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing items.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qrange('q', 0, -1);
</pre>


<a name="m-qslice"></a>
<h3>qslice</h3>

<h4><em>Description</em></h4>
<p>Returns a portion of elements from the queue at the specified range [begin, end]. begin and end could be negative.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>begin</code> - </dd>
	<dd><code>end</code> - </dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error, otherwise an array containing items.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qslice('q', 0, -1);
</pre>



<a name="m-qpush"></a>
<h3>qpush</h3>

<h4><em>Description</em></h4>
<p>This function is an alias of: <code>qpush_back()</code>.</p>


<a name="m-qpush_front"></a>
<h3>qpush_front</h3>

<h4><em>Description</em></h4>
<p>Adds one or more than one element to the head of the queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>item</code> - string or array of string.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>The length of the list after the push operation, <code>false</code> on error.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qpush_front('q', 'a');
</pre>


<a name="m-qpush_back"></a>
<h3>qpush_back</h3>

<h4><em>Description</em></h4>
<p>Adds an or more than one element to the end of the queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>item</code> - string or array of string.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p>The length of the list after the push operation, <code>false</code> on error.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qpush_back('q', 'a');
</pre>


<a name="m-qpop"></a>
<h3>qpop</h3>

<h4><em>Description</em></h4>
<p>This function is an alias of: <code>qpop_front()</code>. </p>


<a name="m-qpop_front"></a>
<h3>qpop_front</h3>

<h4><em>Description</em></h4>
<p>Pop out one or more elements from the head of a queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>size</code> - optional, number of elements to pop, default is 1</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error. When <code>size</code> is not specified or less than 2, returns <code>null</code> if queue empty, otherwise the item removed. When <code>size</code> is specified and greater than or equal to 2, returns an array of elements removed.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qpop_front('q');
</pre>


<a name="m-qpop_back"></a>
<h3>qpop_back</h3>

<h4><em>Description</em></h4>
<p>Pop out one or more elements from the tail of a queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>size</code> - optional, number of elements to pop, default is 1</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error. When <code>size</code> is not specified or less than 2, returns <code>null</code> if queue empty, otherwise the item removed. When <code>size</code> is specified and greater than or equal to 2, returns an array of elements removed.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qpop_back('q');
</pre>


<a name="m-qtrim_front"></a>
<h3>qtrim_front</h3>

<h4><em>Description</em></h4>
<p>Remove multi elements from the head of a queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>size</code> - number of elements to delete.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error. Return the number of elements removed.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qtrim_front('q', 3);
</pre>


<a name="m-qtrim_back"></a>
<h3>qtrim_back</h3>

<h4><em>Description</em></h4>
<p>Remove multi elements from the tail of a queue.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>name</code> - </dd>
	<dd><code>size</code> - number of elements to delete.</dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error. Return the number of elements removed.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;qtrim_back('q', 3);
</pre>






<!-- ##############  other ############## -->

<a name="m-batch"></a>
<h3>batch, exec</h3>

<h4><em>Description</em></h4>
<p>Execute a batch of commands. Batch Commands can reduce the round trip time(rtt) between SSDB client and the server.</p>

<p><b>This feature is implemented in client side, the ssdb-server does not support batch command execution. The server will execute each command as if they are separated. The total amount of the commands and arguments must be less than 10MB.</b></p>

<h4><em>Parameters</em></h4>
<dl>
	<dd></dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>exec()</code> returns <code>false</code> on error, otherwise an array of results corresponding to each of the batch commands.</p>

<h4><em>Example</em></h4>
<pre>
$ret = $ssdb-&gt;batch()
	-&gt;set('a', 1)
	-&gt;get('a')
	-&gt;exec();
// or
$ssdb-&gt;batch();
$ssdb-&gt;set('a', 1);
$ssdb-&gt;get('a');
$ret = $ssdb-&gt;exec();
</pre>


<a name="m-dbsize"></a>
<h3>dbsize</h3>

<h4><em>Description</em></h4>
<p>Return the <b>approximate</b> size of the database, in bytes. If compression is enabled, the size will be of the compressed data.</p>

<h4><em>Parameters</em></h4>
<dl>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error. Return approximate size of the database, in bytes.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;dbsize();
</pre>


<a name="m-info"></a>
<h3>info</h3>

<h4><em>Description</em></h4>
<p>Return information about the server.</p>

<h4><em>Parameters</em></h4>
<dl>
	<dd><code>opt</code> - optional, could be <code>cmd, leveldb</code></dd>
</dl>

<h4><em>Return Value</em></h4>
<p><code>false</code> on error. Return an associative array of information about the server.</p>

<h4><em>Example</em></h4>
<pre>
$ssdb-&gt;info();
</pre>




<div id="footer">
	Copyright&copy;2013,2014 ideawu. All rights reserved.
</div>



</body>
</html>
